﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EFSQLiteOneToManay.AutoMapper
{
    public static class ModelExtension
    {
        public static InspRecord ConfigRecord(this InspRecord record)
        {
            if (record == null) return null;
            if (record.ID == null) record.ID = Guid.NewGuid().ToString().Replace("-","");
            foreach (var group in record.Groups)
            {
                group.GID = record.ID;
                group.ID = Guid.NewGuid().ToString().Replace("-", "");
                foreach (var item in group.Items)
                {
                    item.IID = group.ID;
                    item.ID = Guid.NewGuid().ToString().Replace("-", "");
                    foreach (var s in item.CoordinateDetails)
                        s.CID = item.ID;
                }
            }
            return record;
        }
    }
}
